package daily.kou2022_0227;
//一个队列实现栈

import java.util.LinkedList;
import java.util.Queue;

public class MyQueueByOneQueue  {
    private Queue<Integer> queue = new LinkedList<>();
    public MyQueueByOneQueue () {


    }

    public void push(int x) {
        int size=queue.size();
        queue.offer(x);
        for (int i = 0; i < size; i++) {
            queue.offer(queue.poll());

        }

    }

    public int pop() {
        return queue.poll();


    }

    public int top() {
        return queue.peek();

    }

    public boolean empty() {
        return queue.isEmpty();

    }







}
